using System.Text;
using BizTalk.BuildGenerator.CommandBuilders;

namespace BizTalk.BuildGenerator.FileBuilders
{
    /// <summary>
    /// Builds the App.Build.proj file
    /// </summary>
    public class BuildProjectFileBuilder : IFileBuilder
    {
        private const string FileExtension = ".Build.proj";

        #region IFileBuilder Members

        public void Build(GenerationArgs args)
        {
            StringBuilder fileBuilder = new StringBuilder();
            fileBuilder.Append(Resources.App_Build);
            GenerationTags.ReplaceTags(fileBuilder, args);

            //Do Commands
            ICommandBuilder commandBuilder = new ApplicationResourceCommandBuilder();
            commandBuilder.Build(args, fileBuilder);

            commandBuilder = new BindingFilesCommandBuilder();
            commandBuilder.Build(args, fileBuilder);

            commandBuilder = new PublishedWebServicesCommandBuilder();
            commandBuilder.Build(args, fileBuilder);

            commandBuilder = new UnitTestsCommandBuilder();
            commandBuilder.Build(args, fileBuilder);


            string filePath = args.OutputFolder + @"\" + args.ApplicationDescription.Name + FileExtension;
            FileHelper.WriteFile(filePath, fileBuilder);
        }

        #endregion
    }
}